// pages/ tabs/tabs.js
Component({
  /**
   * 组件的属性列表
   */  
  properties: {
    tabs: {
      type: Array,
      value: []
    }
  },
  //下面代码用于开启多个插槽
  options:{
    multipleSlots: true
  },
  
  /**
   * 组件的初始数据
   */
  data: {
    currentTabIndex:0
  },

  /**
   * 组件的方法列表
   */
  methods: {
  //点击tab的回调
  handleTab(event){
    console.log(event);
    let currentTabIndex = event.currentTarget.dataset.index
    this.setData({
      currentTabIndex
    })
    //向父亲传递消息
    this.triggerEvent("tabEvent",event)
  },
  //滑动之后wxs中handleTouchend的回调
  wxsHandleEnd(diretion){
    console.log('diretiond的值为',diretion);
    console.log(diretion.diretion);
    let {currentTabIndex} = this.data
    console.log('currentTabIndex的值',currentTabIndex);
    if(diretion.diretion === 1){
      //左滑
      console.log('左滑');
      if(currentTabIndex > 0){

        this.setData({
          currentTabIndex: currentTabIndex -1
        })
      }
    }else if(diretion.diretion === -1){
      console.log('右滑');
      if(currentTabIndex < 2){
        this.setData({
          currentTabIndex: currentTabIndex +1
        })
      }
    }
  }
  }
})
